package dto

import (
	"tuowei.com/app/api/models"
	"tuowei.com/common/dto"
	common "tuowei.com/common/models"
)

type SysBalanceDetailGetPageReq struct {
	dto.PaginationNew `search:"-"`
	BuyerId           int `json:"buyer_id" search:"type:exact;column:buyer_id;table:sys_balance_detail" comment:"买家id"` // 买家id
	Change            int `json:"change" search:"type:exact;column:change;table:sys_balance_detail" comment:"1余额收入或者2支出或者3表示提现" `
}

func (m *SysBalanceDetailGetPageReq) GetNeedSearch() interface{} {
	return *m
}

type SysBalanceDetailInsertReq struct {
	BuyerId       int     `comment:"买家id" json:"buyer_id"` //买家id
	Title         string  `gorm:"type:varchar(64);not null;default:'';comment:余额变动标题" json:"title"`
	BalanceChange float64 `gorm:"type:decimal(10,2);comment:余额变动" json:"balance_change"`
	Change        int     `gorm:"type:int(10);not null;default:1;index;comment:1余额收入或者支出" json:"change"`
	BalanceSum    float64 `gorm:"type:decimal(10,2);comment:本次变动后的余额总额" json:"balance_sum"`
	common.ControlBy
}

func (s *SysBalanceDetailInsertReq) Generate(model *models.SysBalanceDetail) {
	model.BuyerId = s.BuyerId
	model.Title = s.Title
	model.BalanceChange = s.BalanceChange
	model.Change = s.Change
	model.BalanceSum = s.BalanceSum
}

func (s *SysBalanceDetailInsertReq) GetId() interface{} {
	return s.BuyerId
}
